<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title>修改密码</title> 
<link href="/assets/background/css/base.css" rel="stylesheet">
<link href="/assets/background/css/backend/modify_pwd.css" rel="stylesheet">
</head> 
<body>
    <div class="container">
        <div id="inner-hd">
            <div class="crumbs">
				<i class="crumbs-arrow"></i>
				<a href="javascript:;" class="crumbs-label">修改密码</a>
			</div>
        </div>

        <div id="inner-bd">

            <div class="button-group">
		        <div class="button current add">
		            <i class="iconfont">&#xe76a;</i>
		            <span class="button-label">保存</span>
		        </div>
		        
		    </div>
			
			<table class="kv-table">
				<tbody>
					<tr>
						<td class="kv-label">
							用户名：
						</td>
						<td class="kv-content" style="padding: 10px;">
							${s.sTrueName }
						</td>
					</tr>
					<tr>
						<td class="kv-label">
							原始密码：
						</td>
						<td class="kv-content" style="padding: 10px;">
							<input type="password" id="password" >
							<span id="pwdspan" class="text-tip" style="display: none;ime-mode:disabled">(原始密码不能为空)</span>
						</td>
					</tr>
					<tr>
						<td class="kv-label">
							新密码：
						</td>
						<td class="kv-content" style="padding: 10px;">
							<input type="password" id="newPassword">
							<span id="Npwdspan" class="text-tip" style="display: none;ime-mode:disabled">(新密码不能为空)</span>
						</td>
					</tr>
					<tr>
						<td class="kv-label">
							确认密码：
						</td>
						<td class="kv-content" style="padding: 10px;">
							<input type="password" id="ConfirmPassword">
							<span id="Cpwdspan" class="text-tip" style="display: none;ime-mode:disabled">(确认密码不能为空)</span>
							
						</td>
					</tr>
				</tbody>
				
			</table>
			
			
        </div>

        <div id="inner-ft">
            
        </div>
    </div>

    <script type="text/javascript" src="/assets/background/js/jquery.js"></script>
    <script type="text/javascript" src="/assets/background/js/global.js"></script>
	<script type="text/javascript" src="/assets/background/js/jquery.select.js"></script>
	<script type="text/javascript" src="/assets/background/js/jquery.pagination.js"></script>
	<script type="text/javascript" src="/assets/background/js/lib/layer/layer.js"></script>
	<script type="text/javascript" src="/assets/background/js/common.js"></script>

	<script type="text/javascript">

		$('select').select();


    $('body').on('click', '.add', function(){
    	
    	var password = $("#password").val();
    	var newPassword = $("#newPassword").val();
    	var ConfirmPassword = $("#ConfirmPassword").val();
    	
    	if(password == ""){
    		$("#pwdspan").html("(原始密码不能为空)");
    		$("#pwdspan").show();
    	}else{
    		$("#pwdspan").hide();
    		if(newPassword == ""){
    			$("#Npwdspan").html("(新密码不能为空)");
    			$("#Npwdspan").show();
    		}else{
    			$("#Npwdspan").hide();
    			if(ConfirmPassword == ""){
    				$("#Cpwdspan").html("(确认密码不能为空)");
    				$("#Cpwdspan").show();
    			}else{
    				$("#Cpwdspan").hide();
    				//检测原始密码是否正常
    				
    				var checkUrl = "/seller/info/pwd/check";
    				$.post(
    						checkUrl,
    						{sPwd:password},
    						function(data){
    							if(data == 1){
    								if(newPassword == password){
    									$("#Npwdspan").html("(新密码不能与原密码相同)");
    					    			$("#Npwdspan").show();
    								}else{
    									if(newPassword == ConfirmPassword){
        									//执行更新密码
            								var updateUrl = "/seller/info/pwd/update";
            								$.post(
            										updateUrl,
            										{sPwd:newPassword},
            										function(data){
            											 layer.open({
            		    							    		title: '密码修改',
            		    							    		content: '修改成功',
            		    							    	});
            											 	//清空信息
            												$("#password").val("");
            										    	$("#newPassword").val("");
            										    	$("#ConfirmPassword").val("");
            										    	//隐藏所有提示信息
            										    	$("#pwdspan").hide();
            										    	$("#Cpwdspan").hide();
            										    	$("#Npwdspan").hide();
            										}
            										);
        								}else{
        									$("#Cpwdspan").html("(确认密码必须与新密码相同)");
        				    				$("#Cpwdspan").show();
        								}
    								}
    								
    								
    								
    							}else{
    								$("#pwdspan").html("(原始密码不正确)");
    					    		$("#pwdspan").show();
    							}
    						}
    				);
    				
    				
    				
    			}
    		}
    	}
    	
    	/* layer.open({
    		title: '加扣分类型操作管理'
    	}); */
    })
	</script>
    
</body> 
</html>
